﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LeetCodeProject
{
    internal class Solution66
    {
        public static int[] PlusOne(int[] digits)
        {
            int acc = 1;
            for (int i = digits.Length-1; i >=0; i--)
            {
                int tmp = digits[i]+acc;
                digits[i] =tmp% 10;
                acc = tmp/10;
            }
            if(acc<=0)return digits;
            else
            {
                int[] res = new int[digits.Length+1];
                res[0] = acc;
                res.Concat(digits);
                return res;
            }
        }
    }
}
